package com.yanqu.road.server.cmd.winery;


import com.yanqu.road.message.YanQuMessage;
import com.yanqu.road.pb.winery.WineryProto;
import com.yanqu.road.server.cmd.base.AbstractCommand;
import com.yanqu.road.server.command.Cmd;
import com.yanqu.road.server.gameplayer.GamePlayer;
import com.yanqu.road.server.gameplayer.module.winery.WineryModule;
import com.yanqu.road.server.protocol.ClientProtocol;
import com.yanqu.road.server.protocol.GameProtocol;

@Cmd(code = GameProtocol.S_WINERY_DRINKER_DRINK, desc = "酒坊酒客喝酒")
public class WineryDrinkerDrinkCmd extends AbstractCommand {

    private WineryProto.WineryDrinkerDrinkReqMsg reqMsg;

    private WineryProto.WineryDrinkerDrinkRespMsg.Builder respMsgBuilder;

    @Override
    public boolean parseData(YanQuMessage packet) throws Exception {
        this.reqMsg = WineryProto.WineryDrinkerDrinkReqMsg.parseFrom(packet.getBytes());
        return true;
    }

    @Override
    public void execute(GamePlayer player, YanQuMessage packet) throws Exception {
        this.respMsgBuilder = player.getModule(WineryModule.class).wineryDrinkerDrink(this.reqMsg);
    }

    @Override
    public void sendData(GamePlayer player) {
        player.sendPacket(ClientProtocol.U_WINERY_DRINKER_DRINK, this.respMsgBuilder);
    }

    @Override
    public boolean isDebug() {
        return true;
    }

    @Override
    public String getRequestData() {
        return this.reqMsg.toString();
    }
}
